﻿// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
//
// LoadPage.xaml.h
// Declaration of the LoadPage class
//

#pragma once

#include "LoadPage.g.h"

namespace Weathr
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    [Windows::Foundation::Metadata::WebHostHidden]
    public ref class LoadPage sealed
    {
    internal:
        LoadPage(Windows::ApplicationModel::Activation::SplashScreen^ splashScreen, const std::function<void ()>& navigatePredicate, const std::function<concurrency::task<void> ()>& asyncLoadFunction, std::shared_ptr<ExceptionPolicy> exceptionPolicy);

    private:
        void PositionImage();
        void DismissedEventHandler(Windows::ApplicationModel::Activation::SplashScreen^ sender, Platform::Object^ e);
        void OnResize(Platform::Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e);
        concurrency::task<void> LoadStateAsync(const std::function<void ()>& loadFunction);

        Windows::Foundation::Rect m_splashImageRect; // Stores splash screen image coordinates.
        Windows::ApplicationModel::Activation::SplashScreen^ m_splash;
        concurrency::event m_dismissed;
        Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ m_args;
        std::shared_ptr<ExceptionPolicy> m_exceptionPolicy;
        Windows::UI::Xaml::Interop::TypeName m_nextPage;
        Windows::Foundation::EventRegistrationToken m_windowSizeEventToken;
    };
}
